<template>
  <div class="all">
    <!-- 按钮栏组件（添加、删除） skipSign:true //跳过检验-->
    <!-- {{sysCompanyCodeRoles}} -->
    <!-- {{getFindByTypeData}} -->
    <el-button type="primary" plain @click="createdAdd" size="mini" icon="el-icon-plus">新建</el-button>
    <!-- <el-button
      class="allDelete"
      type="danger"
      plain
      @click="toDelete"
      size="mini"
      icon="el-icon-delete"
    >批量删除</el-button> -->
    <!-- <div>{{addData.diaDataAdd[1]}}</div>
    <div>{{addData.diaDataAdd[index]}}</div> -->
    <!-- 弹窗 -->
    <el-dialog title="新增" :visible.sync="addData.dialogVisibleAdd" :width="width" :before-close="handleClose"
      :modal="false">
      <div class="list" v-for="(item, index) in addData.diaDataAdd" :key="index" v-if="item.addSign">
        <!-- {{addData.diaDataAdd}} -->
        <template v-if="item.addSign">
          <!-- input框 -->
          <div v-if="item.type === 'input' && item.addSign" class="lister" style="display: flex">
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              <span v-else style="color: white">*</span>
              {{ item.CN }}:
            </span>
            <span class="inb">
              <!-- 标记：{{[item.attr]}} -->
              <!-- {{item}} -->
              <!-- <el-input
                type="textarea"
                :rows="2"
                placeholder="请输入内容"
                v-model="textarea"
                v-if="item.EN==='notes'"
              > -->
              <el-input v-if="item.EN === 'name'" v-model="addData.diaDataAdd[index].value" placeholder="以安装位置命名"
                clearable @blur="BurExp($event, item, index)" size="mini"></el-input>
              <!-- <el-input v-if="item.EN === 'notes' || item.EN === 'memo'" type="textarea" v-model="addData.diaDataAdd[index].value" placeholder="请输入内容" clearable @blur="BurExp($event, item, index)" size="mini"></el-input> -->
              <div v-else-if="item.EN === 'address'" style="display: flex">
                <el-input v-model="mapAddress" placeholder="点击选择地址" clearable :rows="2" size="mini">
                </el-input>
                <el-button size="mini" type="success" @click="showdialogfun" icon="el-icon-location-outline">
                </el-button>
              </div>
              <div v-else-if="item.EN === 'installAddress'" style="display: flex">
                <el-input v-model="address" placeholder="" clearable size="mini">
                </el-input>
              </div>
              <el-input v-model="addData.diaDataAdd[index].value" :placeholder="item.indexConValue || '请输入内容'" clearable
                @blur="BurExp($event, item, index)" size="mini" v-else></el-input>
            </span>
            <el-tooltip v-if="!item.result" class="item" effect="dark" :content="item.err" placement="top">
              <el-button icon="el-icon-warning" circle></el-button>
            </el-tooltip>
            <!-- <span v-if="!item.result" class="font_color"></span> -->
          </div>
          <!-- 计数器 -->
          <div class="lister" :key="index" v-else-if="item.type === 'number' && item.addSign">
            <!-- v-for="(item,index) in addData.diaDataAdd" -->
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              {{ item.CN }}:
            </span>
            <span class="inb">
              <!-- 标记：{{[item.attr]}} -->
              <el-input-number v-model="addData.diaDataAdd[index].value" :min="1" label="描述文字" size="mini">
              </el-input-number>
            </span>
            <el-tooltip v-if="!item.result" class="item" effect="dark" :content="item.err" placement="top">
              <el-button icon="el-icon-warning" circle></el-button>
            </el-tooltip>
          </div>
          <!-- 时间选择 -->
          <div class="lister" :key="index" v-else-if="item.type == 'date' && item.addSign">
            <!-- v-for="(item,index) in addData.diaDataAdd" -->
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              {{ item.CN }}:
            </span>
            <span class="inb" v-if="item.type == 'date' && item.addSign">
              <el-date-picker size="mini" v-model="addData.diaDataAdd[index].value" type="datetime" placeholder="选择日期"
                value-format="yyyy-MM-dd HH:mm:ss" @change="getSTime"></el-date-picker>
            </span>
          </div>
          <!-- 年月日 -->
          <div class="lister" :key="index" v-else-if="item.type == 'datetime' && item.addSign">
            <!-- v-for="(item,index) in addData.diaDataAdd" -->
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              {{ item.CN }}:
            </span>
            <span class="inb" v-if="item.type == 'datetime' && item.addSign">
              <el-date-picker size="mini" v-model="addData.diaDataAdd[index].value" type="date" placeholder="选择日期"
                value-format="yyyy-MM-dd" @change="getSTime"></el-date-picker>
            </span>
          </div>
          <!-- 下拉框 -->
          <div class="lister" :key="index" v-else-if="item.type == 'select' && item.addSign">
            <!-- v-for="(item,index) in addData.diaDataAdd" -->
            <!-- 字典 -->
            <!-- <dictionaries :searchData='diaDataAdd' :modelType='modelType' @optionData="dictionariesCallBack" @optionDataTable="dictionariesTableCallBack"></dictionaries> -->
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              {{ item.CN }}:
            </span>
            <span v-if="item.EN === 'superior'" class="inb">
              <el-cascader v-model="addData.diaDataAdd[index].value" :options="selectOptions"
                :props="{ checkStrictly: true }" clearable></el-cascader>
            </span>
            <!-- <span v-else-if="item.EN === 'productId'">123</span> -->
            <!-- <span v-else-if="item.EN === 'productId'">
             
            </span> -->
            <span v-else class="inb">
              <el-cascader v-if="item.EN === 'organization'" v-model="addData.diaDataAdd[index].value"
                :show-all-levels="false" :options="superiorListOption" clearable>
              </el-cascader>

              <!-- 字典项 typeGroupCode-->
              <el-select v-if="item.typeGroupCode" v-model="addData.diaDataAdd[index].value" placeholder="请选择"
                size="mini" clearable>
                <el-option v-for="i in searchOption[item.EN]" :key="i.value" :label="i.label" :value="i.value">
                </el-option>

                <!-- <el-option v-for="i in item.option" :key="i.value" :label="i.label" :value="i.value"></el-option> -->
              </el-select>
              <!-- 租户管理员页面  --租户框 -->

              <el-select v-else-if="item.EN == 'sysCompanyCode'" v-model="addData.diaDataAdd[index].value"
                placeholder="请选择" size="mini" @change="sysCompanyCodeChange(addData.diaDataAdd[index].value)" clearable>
                <el-option v-for="i in getFindByTypeData" :key="i.value" :label="i.name" :value="i.sysCompanyCode">
                </el-option>
              </el-select>
              <!-- 租户管理员页面  --角色框 -->
              <el-select v-else-if="item.EN == 'groupId'" v-model="addData.diaDataAdd[index].value" placeholder="请选择"
                size="mini" @change="sysRoleChange" clearable>
                <!-- 一个租户只对应一个角色 -->
                <!-- <el-option :label="roleObj.name" :value="roleObj.id"></el-option> -->
                <!-- {{roleArr}} -->
                <el-option v-for="i in roleArr" :key="i.id" :label="i.name" :value="i.id"></el-option>
              </el-select>
              <!-- 字典项 dictTable-->
              <el-select v-else-if="item.dictTable" v-model="addData.diaDataAdd[index].value" placeholder="请选择"
                size="mini" clearable @change="
                  item.EN === 'productId'
                    ? changeproduct(addData.diaDataAdd[index].value)
                    : ''
                ">
                <el-option v-for="i in searchOptions[item.EN]" :key="i.value" :label="i.label" :value="i.value">
                </el-option>
              </el-select>
            </span>
          </div>
          <!-- 多选框 -->
          <div class="Checkbox" :key="index" v-else-if="item.type == 'Checkbox' && item.addSign">
            <span class="fon">
              <span v-if="!item['skipSign']" style="color: red">*</span>
              {{ item.CN }}
            </span>
            <span class="inb" v-if="item.type == 'Checkbox' && item.addSign">
              <el-checkbox v-model="addData.diaDataAdd[index].value"></el-checkbox>
            </span>
          </div>
          <!-- 上传文件 -->
          <div style="margin-left: 14px" v-if="item.type == 'file'">
            <el-upload ref="upload" class="upload-demo" action="/api/cb/flInstallApproval/addNewFile" :limit="1"
              :auto-upload="false" :on-change="handleFileChange" :on-remove="handleFileRemove"
              :show-file-list="isShowFile">
              <div style="display: flex; justify-content: cneter">
                <div>{{ item.CN }}:</div>
                <div v-show="isUploadFile">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="uploadfile" >上传到服务器</el-button> -->
                  <p style="
                      padding: 0;
                      margin: 0;
                      font-size: 8px;
                      margin-left: 10px;
                    ">
                    只能上传一个文件
                  </p>
                </div>
              </div>
            </el-upload>
          </div>
          <!-- 上传图片 -->

          <!-- 滑块 -->
          <div v-if="item.type == 'switch'" style="display: flex">
            <span v-if="!item['skipSign']" style="color: red">*</span>
            <div>{{ item.CN }}:</div>
            <div style="margin-left: 20px">
              <el-switch v-model="switchvalue" active-color="rgb(11,154,195)" inactive-color="#aaaaaa"
                @change="changeswitch">
              </el-switch>
            </div>
          </div>
        </template>
      </div>
      <div v-if="detail" class="inb" style="margin-left: 13px; width: 100%">
        <div style="
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 20px;
          ">
          <p style="padding-right: 8px">*故障详细描述：</p>
          <el-input style="flex: 4" type="textarea" placeholder="请输入内容" v-model="guzhangmiaoshu" maxlength="200"
            show-word-limit></el-input>
        </div>
      </div>
      <div v-if="images" class="inb" style="margin: 15px 0 0 46px; width: 100%">
        <div style="display: flex; align-items: center">
          <div style="padding-right: 10px">现场图片 :</div>
          <el-upload action="" list-type="picture-card" :auto-upload="false" :limit="1" :on-change="handleImageChange"
            :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog :visible.sync="dialogVisible" append-to-body>
            <img width="100%" :src="dialogImageUrl" alt="" />
          </el-dialog>
        </div>
      </div>

      <div v-if="showinfo" class="inb" style="margin-left: 30px; width: 250px">
        <div style="display: flex; align-items: center; justify-content: center">
          <p style="flex: 2">设备厂商：</p>
          <el-input style="flex: 4" size="mini" disabled :value="equipment"></el-input>
        </div>
        <div style="display: flex; align-items: center">
          <p style="flex: 2">联系人：</p>
          <el-input style="flex: 4" size="mini" disabled :value="contacts"></el-input>
        </div>
        <div style="display: flex; align-items: center">
          <p style="flex: 2">联系电话：</p>
          <el-input style="flex: 4" size="mini" disabled :value="contactphone"></el-input>
        </div>
      </div>

      <div style="width: 100%" v-if="ishsowparams">
        <div style="text-align: right">
          <el-button type="primary" size="mini" @click="innerVisible = true">选择参数</el-button>
          <el-button type="primary" size="mini" @click="deleteselect">删除选中</el-button>
        </div>
        <fl-parameter @deleteselectarr="deleteselectarr" :allinorselect="false" :paramarr="paramarr"></fl-parameter>
        <el-dialog width="80%" :visible.sync="innerVisible" append-to-body>
          <fl-parameter @handleSelectionChange="handleSelectionChange" :allinorselect="true"></fl-parameter>
          <span slot="footer">
            <el-button type="primary" size="mini" @click="transmit">确定</el-button>
          </span>
        </el-dialog>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="toAdd" size="mini">确 定</el-button>
        <el-button @click="addData.dialogVisibleAdd = false" size="mini">取 消</el-button>
      </span>
    </el-dialog>
    <div class="tiankuan">
      <el-drawer title="选择安装位置" :visible.sync="showdialog" :direction="direction" :before-close="handleCloselocation"
        :modal-append-to-body="true">
        <div style="margin-left: 20px">
          <div>
            <!-- <el-input v-model="mapsearch" size="mini" placeholder="请输入搜索地址" style="width:300px"></el-input> -->
            <el-autocomplete v-model="mapsearch" :fetch-suggestions="querySearchAsync" :trigger-on-focus="false"
              @input="searchlat" @select="handleSelectScenic" placeholder="请选择地址"></el-autocomplete>
            <!-- <el-button @click="searchlat" size="mini">搜索</el-button> -->
          </div>
        </div>
        <div id="mapp" style="width: 100%; height: 500px; margin-top: 10px"></div>
        <div style="margin-left: 20px; margin-top: 10px">
          <div>当前选择的经纬度为：{{ lnglatcomputed }}</div>
          <div>当前选择的地点为：{{ mapAddress }}</div>
        </div>
        <div class="allr">
          <el-button @click="confirelatlng" type="success" size="mini">确定</el-button>
          <el-button @click="cancelaltlng" type="success" size="mini">关闭</el-button>
        </div>
      </el-drawer>
    </div>
    <!-- <div id="mapp" style="width
          : 200px; height: 200px; background-color: #000"></div> -->
  </div>
</template>

<script>
import {
  getSelectByCodeAndType, //用于添加租户管理员时选择租户后之间传回选择租户的角色：
} from "@/api/TenantAdministratorManagement";
import flParameter from "@/views/collection/base/flProductModel/modifi.vue";
import {
  searchextproductmodel,
  appsgroupbyplatform,
} from "@/api/collection/base/flProductModel/index.js";
// 字典
// import dictionaries from '@/views/components/FLPage/dictionaries'
export default {
  data() {
    return {
      guzhangmiaoshu: "",
      chuanguoqi: {},
      isUploadFile: true,
      isShowFile: false,
      isShowImage: false,
      direction: "rtl",
      // 展示地图遮罩
      showdialog: false,
      contacts: "",
      contactphone: "",
      equipment: "",
      //滑块
      switchvalue: false,
      dialogImageUrl: "",
      dialogVisible: false,
      disabledBathch: false,
      disabled: false,
      // 租户管理员  租户-角色数据
      sysCompanyCodeRolesData: this.$parent.sysCompanyCodeRoles,
      //添加数据模型
      addData: {
        //弹窗控制
        dialogVisibleAdd: false,
        //数据字典
        diaDataAddDictionaries: [],
        //添加弹窗的数据模型
        diaDataAdd: [],
        //确定的disabled，
        mainDisabled: true,
        eventualData: undefined,
      },
      // selectData:[]
      selectOptions: [
        {
          id: 1,
          name: "微山自来水",
          children: [
            {
              id: 2,
              name: "幸福苑小区",
              children: [{ id: 3, name: "1号楼" }],
            },
          ],
        },
        {
          id: 4,
          name: "泗水县",
          children: [
            {
              id: 5,
              name: "花园小区",
              children: [
                { id: 6, name: "1号楼" },
                { id: 7, name: "2号咯" },
                { id: 8, name: "2号咯" },
                { id: 9, name: "2号咯" },
              ],
            },
            {
              id: 10,
              name: "荣盛小区",
            },
          ],
        },
      ],
      superiorData: "",
      // 组件类型
      modelType: "search",
      // 请求到的option
      searchOption: [],
      // 跨表请求option
      searchOptions: [],
      checked: false,
      // 备注  文本域
      textarea: "",
      // 返回的角色对象
      roleArr: [],
      // ishsowparams: false,
      innerVisible: false,
      //将要上传的参数集合
      paramarr: [],
      deletearr: [],
      //上传文件列表
      annexPath: "",
      //上传图片列表
      imgFiles: "",
      // 后端请求回来的模型信息
      productvalue: [],
      nowLat: 39.98412, // 纬度
      nowLng: 116.307484, // 经度
      map: null, // 地图对象
      lat: "",
      lng: "",
      location: "",
      address: "",
      mapAddress: "",
      markerlist: [],
      mapsearch: "",
      map: null,
      maplist: [],
      timeout: "",
      loading: false,
      zoom: 12,
    };
  },
  components: {
    flParameter,
  },
  computed: {
    lnglatcomputed: {
      get() {
        return this.lng != "" && this.lat != ""
          ? this.lng + "," + this.lat
          : "点击标记点";
      },
    },
    //解决v-for v-if在同一标签警告问题
    // TableDataModel() {
    //   let new_DataModel = JSON.parse(JSON.stringify(this.addData.diaDataAdd));
    //   for (let i = 0; i < new_DataModel.length; i++) {
    //     if (!new_DataModel[i].addSign) {
    //       console.log("-------------计算属性-----------");
    //       new_DataModel.splice(i, 1);
    //     }
    //   }
    //   console.log(new_DataModel)
    //   return new_DataModel;
    // }
  },
  props: {
    //添加传过来的值
    diaDataAdd: {},
    optionsZi: {},
    searchOptionTable: {},
    getFindByTypeData: {},
    sysCompanyCodeRoles: {},
    multipleSelection: {},
    ishsowparams: {
      type: Boolean,
      default: false,
    },
    width: {
      type: String,
      default: "760px",
    },
    superiorListOption: {},
    showinfo: {
      type: Boolean,
      default: false,
    },
    images: {
      type: Boolean,
      default: false,
    },
    detail: {
      type: Boolean,
      default: false,
    },
    zhixing: {
      type: Boolean,
      default: true,
    },
  },
  mounted() {
    this.addData.diaDataAdd = JSON.parse(JSON.stringify(this.diaDataAdd));
    //地图初始化函数，本例取名为init，开发者可根据实际情况定义
    // this.initMap();
  },
  methods: {
    confirelatlng() {
      // this.lnglatcomputed = ""
      this.lng = "";
      this.lat = "";
      // this.mapAddress = "";
      this.mapsearch = "";
      this.showdialog = false;
    },
    cancelaltlng() {
      this.lng = "";
      this.lat = "";
      this.showdialog = false;
      this.mapsearch = "";
      this.location = "";
      // this.mapAddress = "";
    },
    zhxing() {
      this.initMap();
    },
    showdialogfun() {
      this.showdialog = true;
      console.log("0000");
      setTimeout(() => {
        this.initMap();
      }, 1);
      // this.initMap();
    },
    setcenter(lng, lat) {
      this.map.setCenter([lng, lat]);
    },
    initMap() {
      this.map = new AMap.Map("mapp", {
        rotateEnable: true,
        pitchEnable: true,
        zoom: this.zoom,
        pitch: 0,
        rotation: 0,
        viewMode: "3D", //开启3D视图,默认为关闭
        center: "",
        terrain: true,
      });

      this.map.on("click", (res) => {
        this.lat = res.lnglat.lat;
        this.lng = res.lnglat.lng;
        this.location = this.lng + "," + this.lat;
        console.log(res);
        // this.map.remove(this.markerlist)
        // 根据经纬度获得详细地址

        this.addmarker();
      });
    },
    searchaddress(lng, lat) {
      var geocoder;
      //加载地理编码插件
      this.map.plugin(["AMap.Geocoder"], () => {
        //加载地理编码插件
        geocoder = new AMap.Geocoder({
          radius: 1000, //以已知坐标为中心点，radius为半径，返回范围内兴趣点和道路信息
          extensions: "all", //返回地址描述以及附近兴趣点和道路信息，默认“base”
        });
        //返回地理编码结果
        geocoder.on("complete", (res) => {
          this.address = res.regeocode.formattedAddress;
          this.mapAddress = res.regeocode.formattedAddress;
          console.log(res, "ressss");
        });
        //逆地理编码
        geocoder.getAddress(new AMap.LngLat(lng, lat));
      });
    },
    addmarker(lng, lat) {
      let marker = new AMap.Marker({
        position: new AMap.LngLat(lng, lat),
        icon: "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
        anchor: "bottom-center",
        zIndex: 1,
      });
      // this.markerlist.push(marker);
      this.map.add(marker);
      AMap.Event.addListener(marker, "click", (res) => {
        console.log(res, "clickmarkerevent");
        let [lng, lat] = [res.lnglat.lng, res.lnglat.lat];
        this.searchaddress(lng, lat);
        this.location = lng + "," + lat;
        this.lng = lng;
        this.lat = lat;
        console.log(this.location);
      });
    },
    // inputsearch() {
    //   if (this.mapsearch !== []) {
    //     console.log(this.mapsearch)
    //     this.searchlat()
    //   }
    // },

    querySearchAsync(queryString, cd) {
      let arr = [];
      this.maplist.forEach((item) => {
        let obj = {
          value: item.address + item.name,
          la: item.location.lng + "," + item.location.lat,
          id: item.id,
          lat: item.location.lat,
          lng: item.location.lng,
        };
        arr.push(obj);
      });
      console.log(arr);
      this.timeout = setTimeout(() => {
        console.log(this.maplist);
        // 调用组件自定方法展示搜索结果
        cd(arr);
      }, 2000 * Math.random());
    },

    handleSelectScenic(item) {
      // item是点击选中的一项
      console.log("item==>", item);
      [this.lng, this.lat, this.address, this.mapAddress, this.location] = [
        item.lng,
        item.lat,
        item.value,
        item.value,
        item.la,
      ];

      this.setcenter(this.lng, this.lat);
      this.maplist.forEach((item) => {
        console.log(item);
        this.addmarker(item.location.lng, item.location.lat);
      });
      this.map.zoom = 8;
    },

    // 地图初始化函数，本例取名为init，开发者可根据实际情况定义
    searchlat() {
      console.log("我执行了");
      this.map.plugin("AMap.PlaceSearch", () => {
        let PlaceSearchOptions = {
          //设置PlaceSearch属性
          city: "全国", //城市
          type: "", //数据类别
          pageSize: 10, //每页结果数,默认10
          pageIndex: 1, //请求页码，默认1
          extensions: "base", //返回信息详略，默认为base（基本信息）
        };
        var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
        console.log(AMap, "amap");
        AMap.Event.addListener(MSearch, "complete", (res) => {
          console.log(res, "我是地图返回值");
          this.maplist = res.poiList.pois;
          console.log(this.maplist);
        }); //返回结果
        MSearch.search(this.mapsearch); //关键字查询
      });
    },
    handleCloselocation(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => { });
    },
    changeproduct(value) {
      console.log(value, "选我");
      this.productvalue.find((item) => {
        if (item.id === value) {
          this.contacts = item.firmContacts;
          this.contactphone = item.firmPhone;
          this.equipment = item.firmFullName;
        }
      });
    },
    //滑块选择回调
    changeswitch(callback) {
      console.log(this.switchvalue);
      this.switchvalue = callback;
    },
    //
    imageshandleRemove(file, fileList) {
      console.log(file, fileList);
    },
    imageshandlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    //文件上传钩子
    // 上传文件执行
    handleFileChange(file) {
      this.isUploadFile = false;
      this.isShowFile = true;
      this.annexPath = file.raw;
      console.log(this.annexPath);
      let data = this.addData.diaDataAdd.filter(function (item) {
        return item.EN == "annexPath";
      });
      data[0].value = file.name;
      let fileData = data[0];
      this.addData.diaDataAdd = this.addData.diaDataAdd.map((item) => {
        if (item.EN == "annexPath") {
          item = fileData;
        }
        return item;
      });
      console.log(this.addData.diaDataAdd, "66666666");
    },
    handleFileRemove(file) {
      this.isUploadFile = true;
    },
    // uploadfile() {
    //   console.log(this.fileList);
    //   this.$refs.upload.submit();
    // },
    // fileonchange(file, fileList) {
    //   this.fileList = fileList;
    // },
    // fileuploadsuccess(file, fileList) {
    //   console.log(file);
    //   this.fileurl = file.data;
    //   console.log(this.fileurl);
    // },
    // filehandleRemove(file, fileList) {
    //   console.log(file, fileList);
    // },
    // filehandlePreview(file) {
    //   console.log(file);
    // },
    // filehandleExceed(files, fileList) {
    //   this.$message.warning(`只能上传一个文件`);
    // },
    // filebeforeRemove(file, fileList) {
    //   return this.$confirm(`确定移除 ${file.name}？`);
    // },
    //图片上传
    handleImageChange(file) {
      this.imgFiles = file.raw;
      // let data = this.addData.diaDataAdd.filter(function (item) {
      //   return item.EN == "imagesPath";
      // })
      // data[0].value = file.name
      // let imageData = data[0]
      // this.addData.diaDataAdd = this.addData.diaDataAdd.map((item) => {
      //   if (item.EN == "imagesPath") {
      //     item = imageData
      //   }
      //   return item;
      // })
      // console.log(this.addData.diaDataAdd, "777777")
    },
    // 过滤重复
    filterRepetition(arr) {
      let arr1 = []; //存id
      let newArr = []; //存新数组
      for (let i in arr) {
        if (arr1.indexOf(arr[i].name) == -1) {
          arr1.push(arr[i].name);
          newArr.push(arr[i]);
        }
      }
      return newArr;
    },
    handleRemove(file) {
      this.$refs.pictureUpload.handleRemove(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    // handleDownload(file) {
    //   console.log(file);
    // },
    // imagesupload(file, fileList) {
    //   let obj = {};
    //   obj.name = fileList.name;
    //   obj.url = file.data;
    //   console.log(obj);
    //   this.imagelist = this.imagelist.concat(obj);
    //   console.log(this.imagelist);
    // },
    //删除选中
    deleteselect() {
      let o = this.paramarr.length;
      let z = this.deletearr.length;
      if (o === z) {
        this.paramarr = [];
        this.deletearr = [];
      } else {
        for (let i = 0; i < o; i++) {
          for (let j = 0; j < z; j++) {
            if (this.paramarr[i].id === this.deletearr[j].id) {
              this.paramarr.splice(i, 1);
            }
          }
        }
      }
      this.deletearr = [];
    },
    //确定传递选择参数
    transmit() {
      this.innerVisible = false;
    },
    // 获取子组件选择的数据
    handleSelectionChange(value) {
      this.paramarr = value;
    },
    deleteselectarr(value) {
      this.deletearr = value;
      console.log(this.deletearr, "deletearr");
    },
    // 角色
    sysRoleChange(newvalue) {
      console.log(8888888888888);

      // this.$emit('sysRoleChangeData',newvalue)
      const roleArrs = this.roleArr;
      console.log(999999999999);

      var id = "";
      for (let index = 0; index < roleArrs.length; index++) {
        const element = roleArrs[index];
        id = roleArrs[index].id;
      }
      this.$emit("sysRoleId", id);
      console.log(id);
    },
    // getFindByTypeData(){
    //   this.getFindByType()
    // },
    //
    // 租户管理员页面  如果改变触发
    async sysCompanyCodeChange(value) {
      console.log(value, "duime");
      // console.log(this.$parent.getSelectByCodeAndTypeData(value));
      const res = await getSelectByCodeAndType(value);
      console.log(
        res,
        "子组件用于添加租户管理员时选择租户后之间传回选择租户的角色"
      );
      const roleObjs = res.data;
      if (roleObjs) {
        console.log(roleObjs);

        this.roleArr = roleObjs;
        // console.log([roleObjs],999999999);
        // console.log(this.roleArr,8888888888888);
      } else {
        console.log("该租户没有对应的角色");
      }

      // console.log(22222222222222222);

      // this.$parent.getSelectByCodeAndTypeData(value)
      // console.log(sysCompanyCodeRoles);

      // console.log(this.sysCompanyCodeRolesData,'99999',res,'sssssss');
    },
    //   获取父级select的数据
    // getSelectData(){
    //     console.log(this.$parent,'ceshikk');

    // },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => { });
    },
    //搜索框内容传递给父元素
    createdAdd() {
      if (this.zhixing) {
        // appsgroupbyplatform().then((res) => {
        //   console.log(res, "9---");
        // });
        // searchextproductmodel()
        //   .then((res) => {
        //     console.log(res, "res");
        //     this.productvalue = res.data;
        //   })
        //   .catch((error) => { });
      }
      this.addData.dialogVisibleAdd = true;
      //清空value;
      for (let i = 0; i < this.addData.diaDataAdd.length; i++) {
        this.addData.diaDataAdd[i].value = "";
        this.addData.diaDataAdd[i].result = true;
      }
    },
    //添加-传给父组件，ajax
    toAdd() {
      console.log(this.chuanguoqi, "1111111111111111");
      var chuanguoqi1 = {
        detail: this.guzhangmiaoshu,
        content: "1111111111",
        faultRiskType: 1,
        longitude: 0,
        latitude: 0,
        address: this.mapAddress,
        // imgFiles: this.imgFiles,
      };
      this.chuanguoqi = chuanguoqi1;
      this.$emit("toAdd", this.addData.diaDataAdd, this.chuanguoqi);

      let bur = true;
      let r;
      if (this.deletearr != "") {
        r = this.deletearr;
      } else {
        r = this.paramarr;
      }
      for (let i = 0; i < this.addData.diaDataAdd.length; i++) {
        let at = this.addData.diaDataAdd[i];
        console.log(at, "at");
        if (at.EN === "decimals") {
          if (at.value.length > 3) {
            this.$message({
              message: "保留小数长度为1-3位的数字!",
              type: "warning",
            });
            return;
          }
        }
        if (at.EN === "location") {
          at.value = this.location;
        }
        if (at.EN === "installAddress") {
          at.value = this.address;
        }
        if (at.EN === "imei") {
          if (at.value.length < 15 || at.value.length > 17) {
            this.$message({
              type: "warning",
              message: "请输入15-17位的IMEI号",
            });
            return;
          }
        }
        if (at.EN === "hydrantNo") {
          if (at.value.length < 3 || at.value.length > 20) {
            this.$message({
              type: "warning",
              message: "请输入3-20位的设备编号",
            });
            return;
          }
        }
        if (at.EN === "isGis" || at.EN === "gisStatus") {
          if (this.switchvalue === false) {
            at.value = 0;
          } else {
            at.value = 1;
          }
        }
        if (at.EN === "organization") {
          at.value = at.value[at.value.length - 1];
        }
        if (at.addSign && !at["skipSign"]) {
          if (at.result === false || at.value === "") {
            // 判断红色星号    是否必须为空
            console.log(at.EN, !at["skipSign"], 22);
            // numberqq +=1
            bur = false;
            break;
          }
        } else {
          if (at.result === false) {
            bur = false;
            break;
          }
        }
      }

      console.log();
      console.log(this.addData.diaDataAdd, "this.addData.diaDataAdd");

      if (bur === true) {
        this.addData.dialogVisibleAdd = false;
        this.address = "";
        this.location = "";
        this.annexPath = "";
        // this.imgFiles = [];
        this.isShowFile = false;
        this.isShowImage = false;
        this.isUploadFile = true;
      } else {
        this.$message({
          message: "请添加全部参数，并符合标准！",
          type: "warning",
        });
      }
    },

    //删除-传给父组件，ajax
    toDelete() {
      this.$emit("toDelete", "点击了删除");
    },

    getSTime(val) {
      this.addData.diaDataAdd.createTime = val;
      // console.log(val)
    },
    //正则表达式
    BurExp(e, item, index) {
      if (this.addData.diaDataAdd[index].skipSign && e.target.value === "") {
        item.result = true;
      } else {
        let boolean = new RegExp(item.Exp).test(e.target.value);
        item.result = boolean;
        this.addData.diaDataAdd[index].result = boolean;
        console.log(item.result, 999);
      }
      // console.log(item, index);
      // console.log( this.addData.diaDataAdd,this.TableDataModel)

      // ----
      // let boolean = new RegExp(item.Exp).test(e.target.value);
      // this.addData.diaDataAdd[index].result = boolean;
      // ----
      // this.TableDataModel[index].result= boolean;
      // let newAobj=this.TableDataModel[index]
      // console.log(boolean);
      // console.log(this.TableDataModel[index]);
    },
    // 新增   租户特殊请求
    getSelectByCodeAndTypeDatas() {
      console.log(this.$parent.getSelectByCodeAndTypeData, "zhegeshishsi");
    },
  },
  created() {
    // this.getSelectData()
    this.getSelectByCodeAndTypeDatas();
  },
  watch: {
    optionsZi(newVal) {
      this.searchOption = newVal;
    },
    searchOptionTable(newVal) {
      this.searchOptions = newVal;
    },
    multipleSelection(newVal) {
      console.log(newVal, 3589);
      if ((newVal, length == 0)) {
        this.disabledBathch = false;
      } else {
        this.disabledBathch = true;
      }
      console.log(newVal, this.disabledBathch, 3589);
    },
    mapsearch(newVal) {
      console.log(Object.prototype.toString.call(newVal));
    },
  },
};
</script>
<style scoped src="@/styles/allCss.css">
</style>
<style lang="scss" scoped>
.tiankuan {
  /deep/.el-drawer__open .el-drawer.rtl {
    margin-top: 0 !important;
  }

  /deep/.el-dialog__close::before {
    color: #666 !important;
    margin: 0 auto;
    position: absolute;
    top: 25px !important;
    right: 20px;
  }
}

.all {
  .latlngtips {
    position: absolute;
    top: 65px;
    left: 0;
    font-size: 14px;
    color: rgb(68, 68, 68);
    padding: 0 15px;
  }

  .allr {
    position: absolute;
    margin-top: 2px;
    right: 30px;
  }

  display: inline-block;

  /deep/.el-dialog__body {
    display: flex;
    flex-wrap: wrap;
  }

  .list {
    .lister {
      height: 44px;
      width: 370px;

      .fon {
        text-align: right;
        margin-right: 14px;
        width: 99px;
      }

      .inb {
        .el-input {
          /deep/.el-input__inner {
            width: 210px;
            height: 30px;
          }
        }

        .el-select {
          /deep/.el-input__inner {
            width: 210px;
            height: 30px;
          }
        }

        .el-textarea {
          /deep/.el-textarea__inner {
            width: 210px;
            height: 60px;
          }
        }
      }
    }

    .is-circle {
      margin-left: 3px;
      padding: 0;
      color: #e69620;
      border: 0;

      /deep/.el-icon-warning {
        height: 14px;
        width: 14px;
      }
    }

    .font_color {
      font-size: 12px;
      padding-left: 100px;
      padding-top: 10px;
    }
  }
}
</style>
